package by.ins.task;

public abstract class Task extends AppThread {
	protected String taskName;
	protected String description;
	protected long id;
	protected Status status;	
	
	public enum Status {
		/**
		 * ManagedTask was not started
		 */
		INACTIVE,

		/**
		 * ManagedTask is running
		 */
		RUNNING,

		/**
		 * ManagedTask is paused. It can be run after calling continue method
		 */
		PAUSED,
		/**
		 * ManagedTask is paused. It will be run after same time.
		 */
		WAIT,

		/**
		 * ManagedTask was stopped by any reason. It will not be running again;
		 */
		CANCELED,

		/**
		 * ManagedTask was finished correctly. It will not be running again;
		 */
		FINISHED,
		/**
		 * 
		 */
		NOSPECIFIED;
		
		
	}


	public Task() {		
		super();	
		this.id = TaskManager.generateTaskID();		
		status = Status.INACTIVE;
		this.setDaemon(false);
		TaskManager.getTaskManager().addTask(this);
		
	}

	public abstract void taskBody();	
	
	public void doTask(){
		
	}
	
	
	public Task(String name, String description) {		
		this();
		this.taskName = name;
		this.description = description;
			
	}

	public String getTaskName() {
		return taskName;
	}

	public String getDescription() {
		return description;
	}

	public long getId() {
		return id;
	}

	public Status getStatus() {

		return status;
	}
	
	@Override
	public String toString() {
		return new StringBuilder("Task id: ").append(id).append(" taskName: ").append(taskName).append(" status: ").append(status).toString();
	}


}
